-
Notifications
You must be signed in to change notification settings - Fork 17
Generate deeplinks instead of calling Cashtab directly #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Cashtab will still be called via a redirection if no app handles the link first. This makes this code compatible with both mobile and desktop with no special case. Works together with PayButton/paybutton-server#1106.
📝 WalkthroughWalkthroughAdds a BIP21→deeplink conversion and uses it for XEC paybutton clicks: Widget now builds a deeplink from a BIP21 URL and calls the payment opener with both the original URL and the deeplink; WidgetContainer defaults apiBaseUrl from Changes
Sequence DiagramsequenceDiagram
participant User as User
participant Widget as Widget Component
participant Converter as convertBip21ToDeeplink
participant Cashtab as openCashtabPayment
User->>Widget: Click PayButton (XEC)
Widget->>Widget: handleButtonClick(bip21Url)
Widget->>Converter: convertBip21ToDeeplink(bip21Url, apiBaseUrl)
Converter-->>Widget: deeplink URL
Widget->>Cashtab: openCashtabPayment(bip21Url, deeplink)
Cashtab-->>User: Open payment app / deeplink handled
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
chedieck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded URL wasn't letting me test locally, so I submitted a commit to fix it.
When testing, after clicking the button I am being correctly redirected to
http://localhost:3000/app?address=ecash%3Aqr64gaal5zx97judme7nmqxpru6gnx8p3uwgvx585h&amount=5&op_return_raw=045041590000001033ab8ab542994e158c6b0c0ddb6ea127&b=1
which is running PayButton/paybutton-server#1106, so I should get redirected to:
https://cashtab.com/#/send?bip21=ecash:qr64gaal5zx97judme7nmqxpru6gnx8p3uwgvx585h?amount=5&op_return_raw=045041590000001033ab8ab542994e158c6b0c0ddb6ea127
... which appears correctly in my logs, as the URL I'll be redirected to.
Nonetheless, I get a flashing error:
... and redirected to the server's dashboard.
| params.set('b', '1') | ||
|
|
||
| // Return absolute URL for the deeplink | ||
| return `https://paybutton.org/app?${params.toString()}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not have the domain hardcoded, we have apiBaseUrl
And move the conversion function outside of the component to make the rabbit happy.
|
I added a commit with the requested fix and the Rabbit suggestion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@react/lib/components/Widget/WidgetContainer.tsx`:
- Line 5: The import at the top of WidgetContainer.tsx currently references a
non-existent module (import config from '../../paybutton-config.json'); change
this to import the existing config (import config from
'../../example-config.json') so the WidgetContainer component can access the
required apiBaseUrl via the config object.
| import { getAltpaymentClient } from '../../altpayment'; | ||
| import { GlobalStyles } from '@mui/material' | ||
|
|
||
| import config from '../../paybutton-config.json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check that the config file exists and inspect its contents
fd 'paybutton-config.json' --type f
if fd 'paybutton-config.json' --type f > /dev/null 2>&1; then
echo "=== File contents ==="
fd 'paybutton-config.json' --type f --exec cat {}
else
echo "File not found"
fiRepository: PayButton/paybutton
Length of output: 84
🏁 Script executed:
#!/bin/bash
# Search for any config-related files
echo "=== Config files in repo ==="
fd -e json --type f | grep -i config | head -20
echo ""
echo "=== Search for paybutton-config references ==="
rg 'paybutton-config' --type ts --type tsx
echo ""
echo "=== Search for apiBaseUrl references ==="
rg 'apiBaseUrl' --type ts --type tsx -A 2 -B 2Repository: PayButton/paybutton
Length of output: 379
🏁 Script executed:
#!/bin/bash
# Check the WidgetContainer file for the config usage
echo "=== WidgetContainer.tsx (first 130 lines) ==="
head -130 "react/lib/components/Widget/WidgetContainer.tsx" | tail -50
echo ""
echo "=== example-config.json ==="
cat "react/lib/example-config.json"
echo ""
echo "=== All files in react/lib ==="
fd --type f --max-depth 1 '' "react/lib"Repository: PayButton/paybutton
Length of output: 1924
Change the import to reference example-config.json instead of the non-existent paybutton-config.json.
The file paybutton-config.json does not exist in the repository. The correct config file is react/lib/example-config.json, which contains the required apiBaseUrl property. Update the import path from import config from '../../paybutton-config.json' to import config from '../../example-config.json'.
🤖 Prompt for AI Agents
In `@react/lib/components/Widget/WidgetContainer.tsx` at line 5, The import at the
top of WidgetContainer.tsx currently references a non-existent module (import
config from '../../paybutton-config.json'); change this to import the existing
config (import config from '../../example-config.json') so the WidgetContainer
component can access the required apiBaseUrl via the config object.
Cashtab will still be called via a redirection if no app handles the link first. This makes this code compatible with both mobile and desktop with no special case.
Works together with PayButton/paybutton-server#1106.
Summary by CodeRabbit